package jp.ne.hatena.d.digitalsoul.warikan.actions

import java.io._
import java.text._

import jp.ne.hatena.d.digitalsoul.warikan.contexts._
import jp.ne.hatena.d.digitalsoul.warikan.pages.forms._
import jp.ne.hatena.d.digitalsoul.warikan.repositories._

class PayingAction extends Serializable {
	
	val format = new SimpleDateFormat("yyyy/MM/dd")
	
	def createMainForm(partyId:Int) = {
		
		val mainFormModel = new PayingMainForm
		val party = PartyRepository.forPartyId(partyId)
		
		mainFormModel.partyName  = party.name
		mainFormModel.schedule  = format.format(party.schedule)
		mainFormModel.location = party.location
		mainFormModel.fee = party.sum
		
		mainFormModel
	}
	
	
	def pay(partyId:Int, fee:Int) = {
		val paying:Paying = new Paying(partyId)
		paying.pay(fee)
		paying.commit
	}

}